package com.xbao.dao;

import com.xbao.model.PeriodRecord;
import com.xbao.model.PeriodRecordExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface PeriodRecordMapper {
    @SelectProvider(type=PeriodRecordSqlProvider.class, method="countByExample")
    int countByExample(PeriodRecordExample example);

    @DeleteProvider(type=PeriodRecordSqlProvider.class, method="deleteByExample")
    int deleteByExample(PeriodRecordExample example);

    @Delete({
        "delete from period_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into period_record (createtime, comments, ",
        "ontime, durationtime, ",
        "orgid, cid, status, ",
        "daytime, subid, endtime, ",
        "ruleid, notify)",
        "values (#{createtime,jdbcType=BIGINT}, #{comments,jdbcType=VARCHAR}, ",
        "#{ontime,jdbcType=BIGINT}, #{durationtime,jdbcType=INTEGER}, ",
        "#{orgid,jdbcType=BIGINT}, #{cid,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, ",
        "#{daytime,jdbcType=BIGINT}, #{subid,jdbcType=BIGINT}, #{endtime,jdbcType=BIGINT}, ",
        "#{ruleid,jdbcType=BIGINT}, #{notify,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(PeriodRecord record);

    @InsertProvider(type=PeriodRecordSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(PeriodRecord record);

    @SelectProvider(type=PeriodRecordSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="ontime", property="ontime", jdbcType=JdbcType.BIGINT),
        @Result(column="durationtime", property="durationtime", jdbcType=JdbcType.INTEGER),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="cid", property="cid", jdbcType=JdbcType.BIGINT),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="daytime", property="daytime", jdbcType=JdbcType.BIGINT),
        @Result(column="subid", property="subid", jdbcType=JdbcType.BIGINT),
        @Result(column="endtime", property="endtime", jdbcType=JdbcType.BIGINT),
        @Result(column="ruleid", property="ruleid", jdbcType=JdbcType.BIGINT),
        @Result(column="notify", property="notify", jdbcType=JdbcType.INTEGER)
    })
    List<PeriodRecord> selectByExample(PeriodRecordExample example);

    @Select({
        "select",
        "id, createtime, comments, ontime, durationtime, orgid, cid, status, daytime, ",
        "subid, endtime, ruleid, notify",
        "from period_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="ontime", property="ontime", jdbcType=JdbcType.BIGINT),
        @Result(column="durationtime", property="durationtime", jdbcType=JdbcType.INTEGER),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="cid", property="cid", jdbcType=JdbcType.BIGINT),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="daytime", property="daytime", jdbcType=JdbcType.BIGINT),
        @Result(column="subid", property="subid", jdbcType=JdbcType.BIGINT),
        @Result(column="endtime", property="endtime", jdbcType=JdbcType.BIGINT),
        @Result(column="ruleid", property="ruleid", jdbcType=JdbcType.BIGINT),
        @Result(column="notify", property="notify", jdbcType=JdbcType.INTEGER)
    })
    PeriodRecord selectByPrimaryKey(Long id);

    @UpdateProvider(type=PeriodRecordSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") PeriodRecord record, @Param("example") PeriodRecordExample example);

    @UpdateProvider(type=PeriodRecordSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") PeriodRecord record, @Param("example") PeriodRecordExample example);

    @UpdateProvider(type=PeriodRecordSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(PeriodRecord record);

    @Update({
        "update period_record",
        "set createtime = #{createtime,jdbcType=BIGINT},",
          "comments = #{comments,jdbcType=VARCHAR},",
          "ontime = #{ontime,jdbcType=BIGINT},",
          "durationtime = #{durationtime,jdbcType=INTEGER},",
          "orgid = #{orgid,jdbcType=BIGINT},",
          "cid = #{cid,jdbcType=BIGINT},",
          "status = #{status,jdbcType=INTEGER},",
          "daytime = #{daytime,jdbcType=BIGINT},",
          "subid = #{subid,jdbcType=BIGINT},",
          "endtime = #{endtime,jdbcType=BIGINT},",
          "ruleid = #{ruleid,jdbcType=BIGINT},",
          "notify = #{notify,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(PeriodRecord record);
}